<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php
  $data['leftnav']=1;$this->load->view('admin/header.html',$data)
?>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validateForm.js"></script>
<script type="text/javascript" src="http://player.youku.com/jsapi"></script>
<script type="text/javascript">
    function Success(data) {
        $.Success(data);
    }
    $(function () {
        $.validate_video('ajax_form');
        $.validate_video('ajax_form1');
    });
    function Del(videoid) {
        layer.confirm("确定删除", function () {
            $.post("/admin/video/delvideo/" + videoid, null, function (data) {
                var jsonData = $.parseJSON(data);
                if (jsonData.Statu == 'ok') {
                    Success(jsonData)
                }
                else {
                    Success(jsonData)
                }
            })
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }

    function _Del(video_listid) {
        layer.confirm("确定删除", function () {
            $.post("/admin/video/DelVideo_list/" + video_listid, null, function (data) {
                var jsonData = $.parseJSON(data);
                if (jsonData.Statu == 'ok') {
                    Success(jsonData)
                }
                else {
                    Success(jsonData)
                }
            })
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }

    function UploadProductVideo() {
        layer.open({
            type: 2,
            title: '视频上传',
            maxmin: true,
            shadeClose: true, //开启点击遮罩关闭层
            area: ['800px', '690px'],
            offset: ['100px', ''],
            content: '/admin/video/uploadvideo',
        });
    }
    function SetVideoIdValue(client_id, v) {
        if (v == null || v == "" || v == undefined) {
            layer.alert("视频上传失败", 3)
        } else {
            $("#video_id").val(v);
            GetVideoInfo(client_id, v)
            layer.msg('上传成功', { icon: 1 });
        }
    }

    function GetVideoInfo(client_id, videoId) {
        showVideo('playvideo', videoId);
    }

    function showVideo(domid, vid) {
        var client_id = "<?php echo !empty($videoModel)?$videoModel->client_id:""?>";
        if (client_id == "") {
            layer.msg('请完善视频设置', { icon: 5 });
        } else {
            player = new YKU.Player(domid, {
                client_id: client_id,
                vid: vid,
                show_related: false
            });
        }
    }
    $(function () {
        var videoId = "<?php echo !empty($video_listModel)?$video_listModel->video_id:"err"?>";
        showVideo('playvideo', videoId);
    })


</script>



<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">DouPHP 管理中心<b>></b><strong>视频设置</strong> </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3>视频设置</h3>
        <form id="ajax_form" action="<?php echo site_url('admin/video/edit_video')?>" method="post">
            <input id="videoid" name="videoid" type="hidden" value="<?php echo !empty($videoModel)?$videoModel->videoid:0?>" />
            <input id="mark" name="mark" type="hidden" value="<?php echo !empty($videoModel)?1:0?>" />

            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <td width="100" align="right">client_id</td>
                    <td>
                        <input type="text" id="client_id" name="client_id" size="40" class="inpMain" value="<?php echo !empty($videoModel)?$videoModel->client_id:""?>" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">client_secret</td>
                    <td>
                        <input type="text" id="client_secret" name="client_secret" size="40" class="inpMain" value="<?php echo !empty($videoModel)?$videoModel->client_secret:""?>" />

                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">refresh_token</td>
                    <td>
                        <input type="text" id="refresh_token" name="refresh_token" size="40" class="inpMain" value="<?php echo !empty($videoModel)?$videoModel->refresh_token:""?>" />

                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <!--<input type="button" onclick="UploadProductVideo()" class="btn" value="视频添加" />-->
                        <input type="submit" class="btn" value="添加" />
                        <?php if(!empty($videoModel)){?>
                        <input type="button" class="btn" onclick="Del(<?php echo $videoModel->videoid?>)" value="删除" />
                        <?php }?>
                    </td>
                </tr>
            </table>
        </form>
        <h3 style="margin-top:25px;">首页视频设置</h3>
        <form id="ajax_form1" action="<?php echo site_url('admin/video/edit_videolist')?>" method="post">
            <input id="video_listid" name="video_listid" type="hidden" value="<?php echo !empty($video_listModel)?$video_listModel->video_listid:0?>" />
            <input id="mark" name="mark" type="hidden" value="<?php echo !empty($video_listModel)?1:0?>" />

            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <td width="100" align="right">视频id</td>
                    <td>
                        <input readonly="readonly" type="text" id="video_id" name="video_id" size="40" class="inpMain" value="<?php echo !empty($video_listModel)?$video_listModel->video_id:""?>" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">视频展示</td>
                    <td>
                        <label class="videostate"></label>
                        <div id="playvideo" style="width:440px;height:400px;"></div>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" onclick="UploadProductVideo()" class="btn" value="<?php echo !empty($video_listModel)?"视频上传":"视频上传"?>" />
                        <input type="submit" class="btn" value="<?php echo !empty($video_listModel)?"修改":"添加"?>" />
                        <?php if(!empty($video_listModel)){?>
                        <input type="button" class="btn" onclick="_Del(<?php echo $video_listModel->video_listid?>)" value="删除" />
                        <?php }?>
                    </td>
                </tr>
            </table>
        </form>
    </div>

</div>
